﻿using UnityEngine;

/// <summary>
/// 此类仅用于配置UI布局
/// </summary>
public class CameraArea : MonoBehaviour
{
    private void Awake()
    {
        gameObject.SetActive(false);
    }

    private void Reset()
    {
        Rect cameraRect = Camera.main.rect;
        Vector2 canvas = GameObject.Find("Canvas").GetComponent<RectTransform>().sizeDelta;

        RectTransform rectTrans = GetComponent<RectTransform>();
        rectTrans.anchoredPosition = new Vector2(cameraRect.x * canvas.x, cameraRect.y * canvas.y);
        rectTrans.sizeDelta = new Vector2(cameraRect.width * canvas.x, cameraRect.height * canvas.y);
    }
}